const {defineConfig} = require('@vue/cli-service')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const webpack = require('webpack');
const {machineId, machineIdSync} = require('node-machine-id')


module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  productionSourceMap: false,
  publicPath: "./",
  devServer: {
    host: 'localhost',
    port: 8181,
    open: true,
    proxy: {
      "/api": {  // target: `http://119.23.63.96:8080`  // 测试
        // target: `http://192.168.0.147:8080`, // 利威
        // target: `http://192.168.0.148:8080`, // 玉龙
        // target: `http://192.168.0.120:8080`, // 发布地址
        // target: `http://39.108.189.64:8080`, // 正式
        target: `http://47.112.112.68:8080`, // 测试
        // target: `http://192.168.0.149:8080`, // 发布地址
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
    }
  },
  configureWebpack: {
    plugins: [
      new NodePolyfillPlugin(),
      new webpack.DefinePlugin({
        VERSION: JSON.stringify(machineIdSync({original: true}))
      })
    ]
  },
  chainWebpack(config) {
    //在组件内使用 scss 定义的变量
    const oneOfsMap = config.module.rule("scss").oneOfs.store;
    oneOfsMap.forEach((item) => {
      item.use("sass-resources-loader")
        .loader("sass-resources-loader")
        .options({
          resources: './src/assets/style/index.scss'
        })
        .end()
    })
  },
})


